import * as Api from '@/api/system/role'

const role = {
  state: {
  },
  mutations: {
  },
  actions: {
    GetRolePage({ commit }, param) {
      return new Promise((resolve, reject) => {
        Api.getRolePage(param)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    GetRoleById({ commit }, id) {
      return new Promise((resolve, reject) => {
        Api.getRoleById(id)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    SaveRole({ commit }, data) {
      return new Promise((resolve, reject) => {
        Api.saveRole(data)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    UpdateRoleById({ commit }, { id, data }) {
      return new Promise((resolve, reject) => {
        Api.updateRoleById(id, data)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    RemoveRoleById({ commit }, id) {
      return new Promise((resolve, reject) => {
        Api.removeRoleById(id)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    }
  }
}

export default role
